<template>

 <tr>
     <td>
      <input type="checkbox" v-model="ischeck">   
     </td>
      <td>
          {{name}}
      </td>
      <td>
           {{price}}
      </td>
       <td>
           <button @click="minus(index)">-</button>
           {{num}}
           <button @click="add(index)">+</button>
      </td>
       <td>
           {{ num * price }}
      </td>
       <td>
          <button>删除</button>
      </td>
  </tr> 
 
</template>

<script>
export default {
    props:['name','price','num','checked','index'],
    data(){
        return {
        ischeck:this.checked
        }
    },
    methods:{
        // 数量加
        add(index){
        this.$emit('add',index)
        },
          // 数量减
        minus(index){
            this.$emit('minus',index)
        }
    },
    watch:{
        ischeck:{
            deep:true,
            handler(check){
              this.$emit('updateCheck',check,this.index)
            }
        },
        checked(change){
             this.ischeck=change
        }
    }
}
</script>

<style>

</style>